version 14.2
set more off
set matsize 11000
set seed 12345
clear all
clear mata

***********************************************************************************************************************
* THIS ROUTINE GENERATES FIGURE A.IV OF WASEEM (2020) ROLE OF WITHHOLDING ...
***********************************************************************************************************************

* MANUFACTURERS VS. IMPORTERS 

clear					all
clear					mata
use 			 		"$project_data\Master Short Updated Nov 2011.dta", clear
keep                	if business_sts=="1" | business_sts=="2"
g						ind=real(substr(item_cd,1,4))
drop					if ind<1600
drop					if ind>=2500 & ind<2800
keep					regno business_sts item_cd date_comm*
g						rweek=wofd(date_comm)
g						treat=business_sts=="1"
g						one=1
bys						rweek treat:egen nregism=sum(one)
keep					if date_comm>=d(01apr2000) & date_comm<d(01dec2000)
g						date=dofw(rweek)
duplicates				drop rweek treat, force
keep					rweek treat nregism date 
local					sa=d(27may2000)
local					ba=d(17jun2000)
local					ss=d(22aug2000)
local					apr=d(01apr2000)
local					may=d(01may2000)
local					jun=d(01jun2000)
local					jul=d(01jul2000)
local					aug=d(01aug2000)
local					sep=d(01sep2000)
local					oct=d(01oct2000)
local					nov=d(01nov2000)
local					dec=d(01dec2000)
#d;
twoway  				(connected  nregism date if treat==1,sort lwidth(thick) lcolor(red) mcolor(red) msymbol(o))
						(connected  nregism date if treat==0,sort lwidth(thick) lcolor(midblue) mcolor(midblue) msymbol(o) lpattern(shortdash)),
						xlabel(`apr' "Apr" `may' "May" `jun' "Jun" `jul' "Jul" `aug' "Aug" `sep' "Sep" `oct' "Oct" `nov' "Nov" `dec' "Dec")
						ytitle(Number of Firms, alignment(bottom)) yscale(r(0))  yscale(titlegap(*10)) 
						xtitle("Week of the Month") xscale(titlegap(*10))
						xline(`sa' `ba' `ss' `jul', lpatter(dash) lcolor(green)) ylabel(0(100)300) 
						legend(region(style(none)) label(1 "Manufacturers") label(2 "Importers") rows(1)) 
						graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white); 	
graph 					export "$project_output\Registration_Weekly_MVsI.eps", replace;
#d						cr

* MANUFACTURERS VS. SERVICE PROVIDERS 

clear					all
clear					mata
use 			 		"$project_data\Master Short Updated Nov 2011.dta", clear
keep                	if business_sts=="1" | business_sts=="8"
g						ind=real(substr(item_cd,1,4))
drop					if ind<1600
drop					if ind>=2500 & ind<2800
keep					regno business_sts item_cd date_comm*
g						rweek=wofd(date_comm)
g						treat=business_sts=="1"
g						one=1
bys						rweek treat:egen nregism=sum(one)
keep					if date_comm>=d(01apr2000) & date_comm<d(01dec2000)
duplicates				drop rweek treat, force
g						period=rweek
qui						sum period
replace					period=period-r(min)+1
keep					rweek treat nregism period 
reshape					wide nregism, i(period) j(treat)
ren						nregism0 nservice
ren						nregism1 nmanuf
recode					nservice(mis=0)
g						date=dofw(rweek)
local					sa=d(28may2000)
local					ba=d(17jun2000)
local					ss=d(28aug2000)
local					apr=d(01apr2000)
local					may=d(01may2000)
local					jun=d(01jun2000)
local					jul=d(01jul2000)
local					aug=d(01aug2000)
local					sep=d(01sep2000)
local					oct=d(01oct2000)
local					nov=d(01nov2000)
local					dec=d(01dec2000)
#d;
twoway  				(connected  nmanuf date,sort lwidth(thick) lcolor(red) mcolor(red) msymbol(o))
						(connected  nservice date,sort lwidth(thick) lcolor(midblue) mcolor(midblue) msymbol(o) lpattern(shortdash)),
						xlabel(`apr' "Apr" `may' "May" `jun' "Jun" `jul' "Jul" `aug' "Aug" `sep' "Sep" `oct' "Oct" `nov' "Nov" `dec' "Dec")
						ytitle(Number of Firms, alignment(bottom)) yscale(r(0))  yscale(titlegap(*10)) 
						xtitle("Week of the Month") xscale(titlegap(*10))
						xline(`sa' `ba' `ss' `jul', lpatter(dash) lcolor(green)) ylabel(0(200)1000)
						legend(region(style(none)) label(1 "Manufacturers") label(2 "Service Providers") rows(1)) 
						graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white); 	
graph 					export "$project_output\Registration_Weekly_MVsS.eps", replace;
#d						cr

